from django.http import JsonResponse
from django.shortcuts import render

# Create your views here.
from cart.models import Cart


def ajax_add_cart(request):
    quantity = request.GET.get("count")
    good = request.GET.get("good")
    cart, created = Cart.objects.update_or_create(quantity=quantity, user=request.user, good_id=good)
    json_str = cart.__dict__
    json_str.pop("_state")
    return JsonResponse(json_str)


